<?php
class RCustomerSitesController extends AppController {

	public $name = 'RCustomerSites';

	function index() {
		$this->RCustomerSite->recursive = 0;
		$this->set('rCustomerSites', $this->paginate());
	}
	
	/***********************************************************
	 * Dashboard
	 **********************************************************/	
	function dashboard() {
		$this->set('rCustomerSites', $this->paginate());
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid r customer site', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('rCustomerSite', $this->RCustomerSite->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->RCustomerSite->create();
			if ($this->RCustomerSite->save($this->data)) {
				$this->Session->setFlash(__('The r customer site has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The r customer site could not be saved. Please, try again.', true));
			}
		}
		$rCustomers = $this->RCustomerSite->RCustomer->find('list');
		$rDesigners = $this->RCustomerSite->RDesigner->find('list');
		$rUpdates = $this->RCustomerSite->RUpdate->find('list');
		$this->set(compact('rCustomers', 'rDesigners', 'rUpdates'));
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid r customer site', true));
			$this->redirect(array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->RCustomerSite->save($this->data)) {
				$this->Session->setFlash(__('The r customer site has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The r customer site could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->RCustomerSite->read(null, $id);
		}
		$rCustomers = $this->RCustomerSite->RCustomer->find('list');
		$rDesigners = $this->RCustomerSite->RDesigner->find('list');
		$rUpdates = $this->RCustomerSite->RUpdate->find('list');
		$this->set(compact('rCustomers', 'rDesigners', 'rUpdates'));
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for r customer site', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->RCustomerSite->delete($id)) {
			$this->Session->setFlash(__('R customer site deleted', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->Session->setFlash(__('R customer site was not deleted', true));
		$this->redirect(array('action' => 'index'));
	}
}
?>